
layui.use(['form'], function() {
    form=layui.form;
    form.on('select(brickType)', function(){
    let departmentid=$("#org option:selected").val().trim();
    var jsonA={
        'departmentid':departmentid
    }
    $.getJSON("/getPosition",jsonA,function(data){
        var optionstring = "";
        $.each(data,function(i,item){
            optionstring += "<option  value=\"" + item.positionid + "\"  name='"+item.sort+"'>" + item.name + "</option>";
        });
        $("#allOpisiton").html('<option value=""></option>' + optionstring);
        $("#positionid").val()
        form.render('select'); //这个很重要
    });
});

    form.on('select(a)', function(){
        let positionid=$("#allOpisiton option:selected").val();
        let sort=$("#allOpisiton option:selected").attr("name");
        $("#positionid").val(positionid)
        $("#sort").val(sort);
        form.render('select'); //这个很重要
    });
});


function saveInfo(){
   let department=$("#org option:selected").text().trim();
   let RecruitmentType=$("#ty").val().trim();
   let numbers=$("#numbers").val().trim();
   let positionName=$("#allOpisiton option:selected").val().trim();
   let positionId=$("#positionid").val().trim();
   let positionSort=$("#sort").val().trim();
   let registrant=$("#registrant").val().trim();
   let expirationDate=$("#expirationDate").val().trim();
   let describe=$("#describe").val().trim();
   let require=$("#require").val().trim();
   let registranTime=$("#registrantTime").val().trim();



   let employment_dyb={
       department:department,
       RecruitmentType:RecruitmentType,
       numbers:numbers,
       positionName:positionName,
       positionId:positionId,
       positionSort:positionSort,
       registrant:registrant,
       expirationDates:expirationDate,
       describe:describe,
       require:require,
       registranTimes:registranTime
   }
   console.log(employment_dyb)
   $.ajaxSettings.async=false;
   $.get('/savePositionInfo',employment_dyb,function (dataA) {
        if (dataA=='1'){
            alert("职业发布成功！")
            location.href="http://localhost:8080/a";
        }else{
            alert("发布失败！")
        }
   })
    $.ajaxSettings.async=true;
}
